Calcifer Calcifer 2 Calcifer 3 Calcifer 4
Python

python3 RSA加密

2019/10/15 13:03 5622 次阅读 王梓
打赏
✸ ✸ ✸
#!/usr/bin/env python
# coding=utf-8
# author: wz
# mail: 277215243@qq.com
# datetime:2019/10/15 12:42 PM
# web: https://www.bthlt.com

from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
import base64

pubkey = """-----BEGIN RSA PUBLIC KEY-----\n
加密码
\n-----END RSA PUBLIC KEY-----\n"""
messages = [
    'userid=test1',
    'userid=test2',
    'userid=test3'
]
for message in messages:
    rsakey = RSA.importKey(pubkey)  
    cipher_rsa = PKCS1_v1_5.new(rsakey)
    message = message.encode(encoding="utf-8")
    cryptedMessage = cipher_rsa.encrypt(message)
    encry_message = base64.b64encode(cryptedMessage)
    print("https://h5.test.qq.com/index?&data={0}".format(encry_message.decode()))
✸ ✸ ✸

📜 版权声明

本文作者:王梓 | 原文链接:https://www.bthlt.com/note/12261423-Pythonpython3 RSA加密

出处:葫芦的运维日志 | 转载请注明出处并保留原文链接

📜 留言板

留言提交后需管理员审核通过才会显示